(旧Siv3D) フォルダ内のすべてのPNG画像をTextureAssetに登録
※アセット名はファイル名を使用
code:loadTextures.cpp
void loadTextures(const FilePath directory)
{
Array<FilePath> contents = FileSystem::DirectoryContents(directory);
for (auto path : contents)
{
if (FileSystem::IsFile(path) && FileSystem::Extension(path) == L"png")
{
TextureAsset::Register(FileSystem::BaseName(path), path);
}
}
}
void Main()
{
// Load "Assets/image1.png", "Assets/image2.png", "Assets/image3.png"
loadTextures(L"Assets");
while (System::Update())
{
TextureAsset(L"image1").draw(0, 0);
TextureAsset(L"image2").draw(100, 0);
TextureAsset(L"image3").draw(200, 0);
}
}